package com.cards_game.simple_ddz.temp;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;

import com.cards_game.simple_ddz.bean.PlayerBean;
import com.cards_game.simple_ddz.bean.UserBean;
import com.cards_game.simple_ddz.common.AllPrimaryContainer;
import com.cards_game.simple_ddz.common.GameProgressEnum;
import com.cards_game.simple_ddz.common.RoomBean;
import com.cards_game.simple_ddz.component.InAndOutRoom;

/**
 * 临时数据模拟
 * 
 * @author 郭国辉
 * 
 *         2017年6月25日上午12:04:39
 */
public class TempDataAnalog {
	public static Map<Integer, UserBean> userMap = new HashMap<>();
	static {
		for (int i = 0; i < 3; i++) {
			UserBean user = new UserBean();
			user.setPassword(i + "");
			user.setUserName("" + i + i);
			user.setUserNum(i + "");
			user.setId(i);
			userMap.put(i, user);
		}
	}
	static volatile boolean flag=false;
	/**
	 * 为0号房模拟添加两个用户
	 */
	public static void addPlayers() {
		if(flag)return;
		flag=true;
		ConcurrentSkipListSet<RoomBean> notFullRooms = AllPrimaryContainer.getAllPrimaryContainer().getNotFullRooms();
		RoomBean rb = notFullRooms.last();
		PlayerBean pb1 = new PlayerBean();
		pb1.setId(0);
		pb1.setReady(true);
		InAndOutRoom.accessRoom(pb1, rb);
		PlayerBean pb2 = new PlayerBean();
		pb2.setId(2);
		pb2.setReady(true);
		InAndOutRoom.accessRoom(pb2, rb);
		rb.setGpe(GameProgressEnum.TWO_READY);
	}
}
